const express = require('express')
const configunits = require('../units')
const router = express.Router()
const Ai = require('../servers/AI')
let serveBody = null
const AILogin = async (req, res, next) => {
    try {
        if (!serveBody || serveBody.status !== 'success') {
            serveBody = await configunits.ailoginsNEXTS()
        }
    } catch (error) {
        serveBody = await configunits.ailoginsNEXTS()
    }
    const body = { ...serveBody.data, ...req.body }
    req.body = body
    next()
}



router.post('/chat', AILogin, Ai.AIvioce)



module.exports = router